package com.heima.wemedia.controller.v1;

import com.heima.model.comment.dtos.*;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmCommentDto;
import com.heima.wemedia.service.WmcommentService;
import com.heima.model.comment.dtos.CommentManageDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/comment/manage")
@Slf4j
public class WmCommentController {

    @Autowired
    private WmcommentService wmcommentService;


    /**
     * 评论显示
     * @param dto
     * @return
     */
    @PostMapping("/find_news_comments")
    public PageResponseResult findAllComment(@RequestBody WmCommentDto dto){
        return wmcommentService.findAllComment(dto);
    }


    /**
     * 打开或者关闭评论
     * @param dto
     * @return
     */
    @PostMapping("/update_comment_status")
    public ResponseResult CloseAndOpenComment(@RequestBody CommentConfigDto dto){
        return wmcommentService.CloseAndOpenComment(dto);
    }


    /**
     * 查看评论列表详情
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody CommentManageDto dto){
        return wmcommentService.list(dto);
    }

    /**
     * 评论回复
     * @param dto
     * @return
     */
    @PostMapping("/comment_repay")
    public ResponseResult CommentRepay(@RequestBody CommentRepaySaveDto dto){

        return wmcommentService.CommentRepay(dto);
    }

    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult delComment(@PathVariable("commentId") String commentId){
        return wmcommentService.delComment(commentId);
    }

    /**
     * 删除评论回复
     * @param commentRepayId
     * @return
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult delCommentRepay(@PathVariable("commentRepayId") String commentRepayId){
        return wmcommentService.delCommentRepay(commentRepayId);
    }

    /**
     * 作者点赞
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return wmcommentService.like(dto);
    }
}
